package com.labirynt.impl;

import java.io.IOException;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;

import com.labirynt.GameObject;

public class Weapon extends GameObject {

	 private Bitmap mBmpMonster;
	public Weapon(String name,String animBmp, int x, int y,int height, int width, Context ctx) {
		super(name, x, y, width, height);
		LoadAnimation(animBmp, ctx);
		this.Initialize(100,1, 4, false);
	//	this.setmBmpPlayer1(mBmpPlayer1);
		
		///frameTimer = 0;
		//currentFrame = 0;
		this.innitMechanicGme(50, 10);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void draw(Canvas canvas) {
		 int width=-120/2;//canvas.getWidth();	
		 int heigh =-132;//canvas.getHeight();
		
				Rect dest = new Rect(width+getXPos(),heigh+ getYPos(), width+getXPos() + spriteWidth,
						heigh+getYPos() + spriteHeight);

				canvas.drawBitmap(mBmpMonster, sRectangle, dest, null);		
				 Paint textPaint;
				 textPaint = new Paint();
		         textPaint.setARGB(255,255,0,115);
		         textPaint.setTextSize(12);
				  canvas.drawText(obiektName ,width+getXPos()-20,heigh+ getYPos()-25, textPaint);
	}

	@Override
	public void Update(long now) {
		// TODO Auto-generated method stub

	}

	
	public void LoadAnimation(String animBmp, Context ctx) {
	
			try
			  {

				this.mBmpMonster=  BitmapFactory.decodeStream(ctx.getAssets().open(animBmp+".png")); 
				} 
			    catch (IOException e) { 
			    	e.printStackTrace(); 
			    }	

	}

	 public boolean isCollision(int x,int y)
	  {
		  return  (( x <this.spriteWidth
		    		&& x>this.xPos)
		    		||( y < this.yPos
		    		&& y > this.spriteHeight
		    		));
		  
	  }
	  
	  public boolean isCollisionWith(GameObject other)  
	  {
	    return  intersectRect( other);
	  }

	@Override
	public void SetPos(int x, int y) {
		// TODO Auto-generated method stub
		
	}

}
